package com.code.day14;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Day14SimpleDateFormat {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = sdf.format(date); //获取当前时间戳转换的地点
        System.out.println("time = " + time);

        System.out.println("===================================");

        String str = "2019-10-10 10:10:10";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = sdf2.parse(str);
        System.out.println("date1 = " + date1);
    }
}
